home *** CD-ROM | disk | FTP | other *** search
/ Clipper Collection / Clipper Collection.iso / clipper7 / clipwind.arc / WDEMO.PRG < prev    next >
Text File  |  1988-03-24  |  35KB  |  1,056 lines

  1. ******************************************************************************
  2. * Program:  WDEMO.PRG                                                         *
  3. * Author:   Jim Holley                                                        *
  4. *           1346 Woodington Cir.                                              *
  5. *           Lawrenceville, Ga. 30245     Ph. # 404-564-3647                   *
  6. * Date:     Start 12/30/87 - Continuing                                       *
  7. * Notice: Copyright (C) 1986, 1987, 1988 Jim Holley, All Rights Reserved.     *
  8. * Version: 2.0                                                                *
  9. * Notes:                          Window Demo.                                *
  10. *                                                                             *
  11. *   This is the original Demo program distributed with Windows For Clipper.   *
  12. * It is included for informational purposes only.                             *
  13. *                                                                             *
  14. * This is a demo of the Windows For Clipper routines. It demonstrates most of *
  15. * the functions that are available to the clipper programmer. All functions   *
  16. * are in the library CLIPWIND.LIB.                                            *
  17. *                                                                             *
  18. * For more information on Windows For Clipper, contact Jim Holley at the      *
  19. * above address or by calling                                                 *
  20. * 404-564-3647 after  6 on weekdays, anytime on weekends.                     *
  21. * To purchase directly send check or money order to the above address.        *
  22. * For check purchases, please allow 3 to 4 weeks for delivery.                *
  23. * The price for Windows for Clipper library is $44.95.                        *
  24. * Georgia residence add appriate sales tax. Please see the REGISTER.DOC file  *
  25. * included.                                                                   *
  26. *                                                                             *
  27. * At this point in time I am unable to accept credit card purchases. This     *
  28. * may be remedied in the future.                                              *
  29. *******************************************************************************
  30.  
  31. ***********************
  32. * turn the cursor off *
  33. ***********************
  34. SET CURSOR OFF
  35.  
  36. ******************
  37. * set enviroment *
  38. ******************
  39. SET SCOREBOARD OFF
  40.  
  41. *******************************
  42. * initialize needed variables *
  43. *******************************
  44. single = 218
  45. double = 201
  46. messrow = 23
  47. scroll = 0
  48. Store 0 to wn1, wn2, wn3, wn4, wn5, wn6
  49.  
  50.  
  51. ************************************
  52. * create opening windows and check *
  53. * to make sure windows are created *
  54. ************************************
  55. wn1 = _sinit_wn(23,6,28,9)
  56. IF wn1 = 0
  57.    @ messrow,0 SAY "Unable to create window wn1"
  58.    WAIT
  59.    RETURN
  60. ENDIF
  61. wn2 = _sinit_wn(24,7,28,9)
  62. IF wn2 = 0
  63.    @ messrow,0 SAY "Unable to create window wn2"
  64.    WAIT
  65.    RETURN
  66. ENDIF
  67. wn3 = _sinit_wn(25,8,28,9)
  68. IF wn3 = 0
  69.    @ messrow,0 SAY "Unable to create window wn3"
  70.    WAIT
  71.    RETURN
  72. ENDIF
  73. wn4 = _sinit_wn(26,9,28,9)
  74. IF wn4 = 0
  75.    @ messrow,0 SAY "Unable to create window wn4"
  76.    WAIT
  77.    RETURN
  78. ENDIF
  79. wn5 = _sinit_wn(27,10,28,9)
  80. IF wn5 = 0
  81.    @ messrow,0 SAY "Unable to create window wn5"
  82.    WAIT
  83.    RETURN
  84. ENDIF
  85. wn6 = _sinit_wn(0,0,8,2)
  86. IF wn6 = 0
  87.    @ messrow,0 SAY "Unable to create window wn6"
  88.    WAIT
  89.    RETURN
  90. ENDIF
  91.  
  92. *******************************
  93. * set window border character *
  94. *******************************
  95. IF .NOT. _sst_wnbc(wn1, double)
  96.    @ messrow,0 SAY "Unable to set border character. Default of Space used."
  97. ENDIF
  98. IF .NOT. _sst_wnbc(wn2, double)
  99.    @ messrow,0 SAY "Unable to set border character. Default of Space used."
  100. ENDIF
  101. IF .NOT. _sst_wnbc(wn3, double)
  102.    @ messrow,0 SAY "Unable to set border character. Default of Space used."
  103. ENDIF
  104. IF .NOT. _sst_wnbc(wn4, double)
  105.    @ messrow,0 SAY "Unable to set border character. Default of Space used."
  106. ENDIF
  107. IF .NOT. _sst_wnbc(wn5, double)
  108.    @ messrow,0 SAY "Unable to set border character. Default of Space used."
  109. ENDIF
  110.  
  111. *******************************
  112. * set window color (contents) *
  113. *******************************
  114. IF .NOT. _sst_wncl(wn1, "b/o/h/", "C")
  115.    @ messrow, 0 SAY "Unable to set color for contents in wn1"
  116. ENDIF
  117. IF .NOT. _sst_wncl(wn2, "b/m/h/", "C")
  118.    @ messrow, 0 SAY "Unable to set color for contents in wn2"
  119. ENDIF
  120. IF .NOT. _sst_wncl(wn3, "b/c/h/", "C")
  121.    @ messrow, 0 SAY "Unable to set color for contents in wn3"
  122. ENDIF
  123. IF .NOT. _sst_wncl(wn4, "b/g/h/", "C")
  124.    @ messrow, 0 SAY "Unable to set color for contents in wn4"
  125. ENDIF
  126. IF .NOT. _sst_wncl(wn5, "b/w//", "C")
  127.    @ messrow, 0 SAY "Unable to set color for contents in wn5"
  128. ENDIF
  129.  
  130. *****************************
  131. * set window color (border) *
  132. *****************************
  133. IF .NOT. _sst_wncl(wn1, "b/w//", "B")
  134.    @ messrow, 0 SAY "Unable to set color for border in wn1"
  135. ENDIF
  136. IF .NOT. _sst_wncl(wn2, "b/w//", "B")
  137.    @ messrow, 0 SAY "Unable to set color for border in wn2"
  138. ENDIF
  139. IF .NOT. _sst_wncl(wn3, "b/w//", "B")
  140.    @ messrow, 0 SAY "Unable to set color for border in wn3"
  141. ENDIF
  142. IF .NOT. _sst_wncl(wn4, "b/w//", "B")
  143.    @ messrow, 0 SAY "Unable to set color for border in wn4"
  144. ENDIF
  145. IF .NOT. _sst_wncl(wn5, "b/w//", "B")
  146.    @ messrow, 0 SAY "Unable to set color for border in wn5"
  147. ENDIF
  148.  
  149. *********************************
  150. * draw the window on the screen *
  151. *********************************
  152. _sdrw_wn(wn1)
  153.  
  154. *********************
  155. * write text to wn1 *
  156. *********************
  157. _swte_txt(wn1, " ")
  158. _swte_txt(wn1, "   They're easy to use  ")
  159. _swte_txt(wn1, " ")
  160. _swte_txt(wn1, "     Not confusing.")
  161.  
  162. *********************************
  163. * draw the window on the screen *
  164. *********************************
  165. _sdrw_wn(wn2)
  166.  
  167. *********************
  168. * write text to wn2 *
  169. *********************
  170. _swte_txt(wn2, " ")
  171. _swte_txt(wn2, "   They're Very fast    ")
  172. _swte_txt(wn2, " ")
  173. _swte_txt(wn2, "      Not Clunkers.")
  174.  
  175. *********************************
  176. * draw the window on the screen *
  177. *********************************
  178. _sdrw_wn(wn3)
  179.  
  180. *********************
  181. * write text to wn3 *
  182. *********************
  183. _swte_txt(wn3, " ")
  184. _swte_txt(wn3, "   They need very little")
  185. _swte_txt(wn3, "   ram to operate.")
  186. _swte_txt(wn3, "  ")
  187.  
  188. *********************************
  189. * draw the window on the screen *
  190. *********************************
  191. _sdrw_wn(wn4)
  192.  
  193. *********************
  194. * write text to wn4 *
  195. *********************
  196. _swte_txt(wn4, " ")
  197. _swte_txt(wn4, " Designed specifically")
  198. _swte_txt(wn4, "        for the" )
  199. _swte_txt(wn4, "   Clipper Compiler")
  200.  
  201. *********************************
  202. * draw the window on the screen *
  203. *********************************
  204. _sdrw_wn(wn5)
  205.  
  206. *********************
  207. * write text to wn5 *
  208. *********************
  209. _swte_txt(wn5, "    WINDOWS FOR CLIPPER")
  210. _swte_txt(wn5, "        Version 1.0")
  211. _swte_txt(wn5, "       By Jim Holley")
  212. _swte_txt(wn5, "   1346 Woodington Cir.")
  213. _swte_txt(wn5, "  Lawrenceville Ga, 30245")
  214. _swte_txt(wn5, " ")
  215. _swte_txt(wn5, " Clipper is a trademark of")
  216. _swte_txt(wn5, "    Nantucket Corp.")
  217.  
  218. *******************************
  219. * set window border character *
  220. *******************************
  221. if .not. _sst_wnbc(wn6, single)
  222.    @ messrow,0 SAY "Unable to set border character. Default of Space used."
  223. endif
  224.  
  225. *******************************
  226. * set window color (contents) *
  227. *******************************
  228. _sst_wncl(wn6, "b/w//", "C")
  229.  
  230. *********************************
  231. * draw the window on the screen *
  232. *********************************
  233. _sdrw_wn(wn6)
  234.  
  235. *********************
  236. * write text to wn6 *
  237. *********************
  238. _swte_txt(wn6, "Clipper")
  239. _swte_txt(wn6, " Windows")
  240.  
  241. @ messrow,0
  242. @ messrow,0 SAY "Press Any Key To Continue."
  243.  
  244. ******************************************************
  245. * set up loop to make windows move around the screen *
  246. ******************************************************
  247. loopsw = .T.
  248. DO WHILE loopsw
  249.    wnrow = 0
  250.    **************************************************
  251.    * this loop moves window right across the screen *
  252.    **************************************************
  253.    FOR wncol = 10 TO 60 STEP 10
  254.       delay = 0
  255.       **********************************************
  256.       * move the window to new column, row coords. *
  257.       **********************************************
  258.       _smove_wn(wn6, wncol, wnrow)
  259.       key = INKEY()     
  260.       IF key <> 0
  261.          loopsw = .F.
  262.          EXIT
  263.       ENDIF
  264.       DO WHILE delay <= 500
  265.          delay = delay + 1
  266.       ENDDO
  267.    NEXT
  268.    IF .NOT. loopsw
  269.       LOOP
  270.    ENDIF
  271.    *****************************************************
  272.    *  this loop moves window down right side of screen *
  273.    *****************************************************
  274.    FOR wnrow = 0 TO 20 STEP 5
  275.       delay = 0
  276.       **********************************************
  277.       * move the window to new column, row coords. *
  278.       **********************************************
  279.       _smove_wn(wn6, wncol, wnrow)
  280.       key = INKEY()     
  281.       IF key <> 0
  282.          loopsw = .F.
  283.          EXIT
  284.       ENDIF
  285.       DO WHILE delay <= 500
  286.          delay = delay + 1
  287.       ENDDO
  288.    NEXT
  289.    IF .NOT. loopsw
  290.       LOOP
  291.    ENDIF
  292.    wnrow = 20
  293.    *************************************************
  294.    * this loop moves window left across the screen *
  295.    *************************************************
  296.    FOR wncol = 60 TO 10 STEP -10
  297.       delay = 0
  298.       _smove_wn(wn6, wncol, wnrow)
  299.       key = INKEY()     
  300.       IF key <> 0
  301.          loopsw = .F.
  302.          EXIT
  303.       ENDIF
  304.       **********************************************
  305.       * move the window to new column, row coords. *
  306.       **********************************************
  307.       DO WHILE delay <= 500
  308.          delay = delay + 1
  309.       ENDDO
  310.    NEXT
  311.    IF .NOT. loopsw
  312.       LOOP
  313.    ENDIF
  314.    *************************************************
  315.    * this loop moves window up left side of screen *
  316.    *************************************************
  317.    wncol = 0
  318.    FOR wnrow = 20 TO 0 STEP -5
  319.       delay = 0
  320.       **********************************************
  321.       * move the window to new column, row coords. *
  322.       **********************************************
  323.       _smove_wn(wn6, wncol, wnrow)
  324.       key = INKEY()     
  325.       IF key <> 0
  326.          loopsw = .F.
  327.          EXIT
  328.       ENDIF
  329.       DO WHILE delay <= 500
  330.          delay = delay + 1
  331.       ENDDO
  332.    NEXT
  333. ENDDO
  334.  
  335. ************
  336. * home wn6 *
  337. ************
  338. _smove_wn(wn6,0,0)
  339.  
  340. *************************
  341. * erase wn6 from screen *
  342. * it will be used again *
  343. *************************
  344. _swnerase(wn6)
  345.  
  346. @ messrow,0
  347. @ messrow,20 SAY "Press Any Key To Continue."
  348.  
  349. ********************************
  350. * remove windows one at a time *
  351. ********************************
  352. INKEY(0)
  353. _srem_wn(wn5)
  354. INKEY(0)
  355. _srem_wn(wn4)
  356. INKEY(0)
  357. _srem_wn(wn3)
  358. INKEY(0)
  359. _srem_wn(wn2)
  360. INKEY(0)
  361. _srem_wn(wn1)
  362.  
  363. ***************************************************************
  364. * change the deminsions of wn6 to have 40 columns and 23 rows *
  365. ***************************************************************
  366. _swnchg(wn6,40,23)
  367.  
  368. ********************
  369. * set window color *
  370. ********************
  371. _sst_wncl(wn6, "b/m//","C")
  372. _sst_wncl(wn6, "b/m//","B")
  373.  
  374. ***************************************************
  375. * draw wn6 back to the screen with new deminsions *
  376. ***************************************************
  377. _sdrw_wn(wn6)
  378.  
  379. *********************
  380. * write text to wn6 *
  381. *********************
  382. _swte_txt(wn6, " This is a demonstration of Windows")
  383. _swte_txt(wn6, " For Clipper. A library of window")
  384. _swte_txt(wn6, " routines for the Clipper Programmer.")
  385. _swte_txt(wn6, " The library contains all the basic ")
  386. _swte_txt(wn6, " functions to allow window creation")
  387. _swte_txt(wn6, " and manipulation. The library was ")
  388. _swte_txt(wn6, " written in 'C' and assembler to give")
  389. _swte_txt(wn6, " peak performance and small code size.")
  390. _swte_txt(wn6, " At link time, only the functions your")
  391. _swte_txt(wn6, " program requires are linked, unlike")
  392. _swte_txt(wn6, " the extend UDF's that come with the")
  393. _swte_txt(wn6, " Clipper package, where all functions")
  394. _swte_txt(wn6, " are linked whether you need them or")
  395. _swte_txt(wn6, " not. The library consists of ")
  396. _swte_txt(wn6, " 1. Window initialization and control")
  397. _swte_txt(wn6, "    functions.")
  398. _swte_txt(wn6, " 2. Window output functions.")
  399. _swte_txt(wn6, " 3. Window input functions.")
  400. _swte_txt(wn6, " There is also special functions for ")
  401. _swte_txt(wn6, " use with databases.")
  402. _swte_txt(wn6, " ")
  403. _swte_txt(wn6, " ")
  404. _swte_txt(wn6, "       Press Any Key To Continue ")
  405. INKEY(0)
  406. ****************************
  407. * remove wn6 from memory   *
  408. * we are going to redefine *
  409. * it with a different      *
  410. * location and size        *
  411. ****************************
  412. _srem_wn(wn6)
  413.  
  414. *************************************
  415. * set to 0 so that it can be tested *
  416. *************************************
  417. wn6 = 0
  418.  
  419. ************************
  420. * get wn6 window again *
  421. ************************
  422. wn6 = _sinit_wn(16,0,47,6)
  423.  
  424. ************************************************
  425. * test to make sure the window was initialized *
  426. ************************************************
  427. IF wn6 = 0
  428.    @ messrow,0 SAY "Unable to create window wn6"
  429.    WAIT
  430. ELSE
  431.    *******************************
  432.    * set window border character *
  433.    *******************************
  434.    IF .NOT. _sst_wnbc(wn6, single)
  435.       @ messrow,0 SAY "Unable to set border character. Default of Space used."
  436.    ENDIF
  437.  
  438.    ********************
  439.    * set window color *
  440.    ********************
  441.    _sst_wncl(wn6, "b/w/h/","C")
  442.    _sst_wncl(wn6, "b/w/h/","B")
  443.  
  444. ENDIF
  445.  
  446.  
  447. DO WHILE .T.
  448.    SET DELIMITERS TO DEFAULT
  449.  
  450.    ******************
  451.    * Turn cursor on *
  452.    ******************
  453.    SET CURSOR ON
  454.  
  455.    ************************************************
  456.    * this first section just asks for preliminary *
  457.    * information to establish the window          *
  458.    ************************************************
  459.    
  460.    STORE 0 TO trow, tcol, numcol, numrow
  461.    STORE SPACE(78) TO text1, text2, text3, text4, text5, text6
  462.    bchar = " "
  463.    bcolor = "       "
  464.    ccolor = "       "
  465.    IF wn6 <> 0
  466.       ***********************************************************
  467.       * This next section demonstates that Clipper can be used  *
  468.       * to write to, and read from a window. The difference is, *
  469.       * you have to calculate the start and stop coordinates,   *
  470.       * and you have to maintain the color selection using the  *
  471.       * SET COLOR command.                                      *
  472.       ***********************************************************
  473.       CLEAR
  474.       _sdrw_wn(wn6)
  475.       SET COLOR TO W+/B
  476.       @ 01,17 SAY " Clipper Window  - Interactive Demonstartion "
  477.       @ 02,17 SAY "═════════════════════════════════════════════"
  478.       @ 03,17 SAY " Enter Starting row      "  GET trow PICTURE "99" VALID(trow >= 0 .AND. trow < 23)
  479.       @ 04,17 SAY " Enter Starting Column   "  GET tcol PICTURE "99" VALID(tcol >= 0 .AND. tcol < 77)
  480.       @ 05,17 SAY " Enter Number of columns "  GET numcol PICTURE "99" VALID(numcol > 1)
  481.       @ 06,17 SAY " Enter Number Of Rows    "  GET numrow PICTURE "99" VALID(numrow > 1)
  482.       SET COLOR TO
  483.    ELSE
  484.       ***********************************************
  485.       * Just in case the window wasn't initialized. *
  486.       ***********************************************
  487.       CLEAR
  488.       @ 0,10 SAY "Clipper Window  - Interactive Demonstartion"
  489.       @ 1,10 SAY "Enter Starting row      " GET trow PICTURE "99"
  490.       @ 2,10 SAY "Enter Starting Column   " GET tcol PICTURE "99"
  491.       @ 3,10 SAY "Enter Number of columns " GET numcol PICTURE "99"
  492.       @ 4,10 SAY "Enter Number Of Rows    " GET numrow PICTURE "99"
  493.    ENDIF
  494.    READ
  495.    CLEAR GETS
  496.    ***************************************************
  497.    * Get some text to show off the scrolling feature *
  498.    ***************************************************
  499.    @ 8,10 SAY "Please Enter some text to be printed in the window"
  500.    SET DELIMITERS TO "[]"
  501.    SET DELIMITERS ON
  502.    SET INTENSITY OFF
  503.    @ 9,0 GET text1
  504.    IF numrow > 2
  505.       @ 10,0 GET text2
  506.    ENDIF
  507.    IF numrow > 3
  508.       @ 11,0 GET text3
  509.    ENDIF
  510.    IF numrow > 4
  511.       @ 12,0 GET text4
  512.    ENDIF
  513.    IF numrow > 5
  514.       @ 13,0 GET text5
  515.    ENDIF
  516.    IF numrow > 6
  517.       @ 14,0 GET text6
  518.    ENDIF
  519.    READ
  520.  
  521.    *****************************
  522.    * Ask a couple of questions *
  523.    *****************************
  524.    SET INTENSITY ON
  525.    @ 8,0 CLEAR
  526.    @ 8,10 SAY "Do You Want a (S)ingle Or (D)ouble Border <S/D>";
  527.    GET bchar PICTURE "!" VALID(bchar $"SD")
  528.    READ
  529.    answer = " "
  530.    @ 8,0 CLEAR
  531.    @ 8,10 SAY "Do You Wish To Set The Window Colors (Y/N) ";
  532.    GET answer PICTURE "!" VALID(answer $"YN")
  533.    READ
  534.  
  535.    **********************
  536.    * Process the answer *
  537.    **********************
  538.    IF answer = "Y"
  539.       @  8,0 CLEAR
  540.       @  8,5 SAY 'The window color set format is "background/foreground/Intensity/Blinking"'
  541.       @  9,10 SAY "To set colors you use the following color codes."
  542.       @ 10,10 SAY "          A        ==        BLACK"
  543.       @ 11,10 SAY "          B        ==        BLUE"
  544.       @ 12,10 SAY "          G        ==        GREEN"
  545.       @ 13,10 SAY "          C        ==        CYAN"
  546.       @ 14,10 SAY "          R        ==        RED"
  547.       @ 15,10 SAY "          M        ==        MAGENTA"
  548.       @ 16,10 SAY "          O        ==        BROWN"
  549.       @ 17,10 SAY "          W        ==        WHITE"
  550.       @ 18,10 SAY "          H        ==        HIGH INTENSITY"
  551.       @ 19,10 SAY "          L        ==        BLINKING"
  552.       @ 21,10 SAY "In order to set high intensity, put an H in the high intensity slot,"
  553.       @ 22,10 SAY "put a L in the Blinking spot, otherwise leave them empty."
  554.       @ 23,10 SAY 'EXAMPLE         "b/o/h/l"'
  555.       @ 24,10 SAY "Enter the color code string for the border" ;
  556.               GET bcolor PICTURE "!!!!!!!" VALID(LEN(bcolor) > 0)
  557.       READ
  558.       @ 24,0
  559.       @ 24,10 SAY "Enter the color code string for the contents" ;
  560.               GET ccolor PICTURE "!!!!!!!" VALID(LEN(ccolor) > 0)
  561.       READ
  562.    ENDIF
  563.  
  564.    ****************************************************
  565.    * ready now to demonstrate the windowing functions *
  566.    * initialize the user defined window               *
  567.    ****************************************************
  568.    wn1 = _sinit_wn(tcol, trow, numcol, numrow)
  569.  
  570.    ***********************************************
  571.    * if wn1 = 0, window initialization failed    *
  572.    * due to insufficient memory. Test it and see *
  573.    ***********************************************
  574.    IF wn1 = 0        
  575.       @ messrow,0 SAY "Not enough memory to execute window functions."
  576.       EXIT
  577.    ENDIF
  578.  
  579.    ****************************************************************
  580.    * window initialization complete. Now set the border character *
  581.    * Test bchar to find out what kind of border                   *
  582.    ****************************************************************
  583.    IF bchar = "D"
  584.       IF .NOT. _sst_wnbc(wn1, double)
  585.          @ messrow,0 SAY "Unable to set border character. Default of Space used."
  586.       ENDIF
  587.    ELSE
  588.       IF .NOT. _sst_wnbc(wn1, single)
  589.          @ messrow,0 SAY "Unable to set border character. Default of Space used."
  590.       ENDIF
  591.    ENDIF
  592.  
  593.    **************************************
  594.    * Border character of some type set. *
  595.    * Ready to set color if selected     *
  596.    **************************************
  597.    IF answer = "Y"
  598.       _sst_wncl(wn1, bcolor, 'B')
  599.       _sst_wncl(wn1, ccolor, 'C')
  600.  
  601.       *************************************
  602.       * Clear the "Set Window Color" text *
  603.       *************************************
  604.       @ 8,0 CLEAR
  605.    ENDIF
  606.  
  607.    *******************
  608.    * Turn cursor off *
  609.    *******************
  610.    SET CURSOR OFF
  611.  
  612.    ******************************************
  613.    * Ready to put the window on the screen. *
  614.    ******************************************
  615.    IF .NOT. _sdrw_wn(wn1)
  616.       @ messrow, 0 SAY "Unable to draw window on screen"
  617.       EXIT
  618.    ENDIF
  619.  
  620.    ******************************************
  621.    * window now on screen, so write the     *
  622.    * text to the window, if it's available. *
  623.    ******************************************
  624.    IF LEN(TRIM(text1)) > 0
  625.       _swte_txt(wn1, text1)
  626.    ENDIF
  627.    IF LEN(TRIM(text2)) > 0
  628.       _swte_txt(wn1, text2)
  629.    ENDIF
  630.    IF LEN(TRIM(text3)) > 0
  631.       _swte_txt(wn1, text3)
  632.    ENDIF
  633.    IF LEN(TRIM(text4)) > 0
  634.       _swte_txt(wn1, text4)
  635.    ENDIF
  636.    IF LEN(TRIM(text5)) > 0
  637.       _swte_txt(wn1, text5)
  638.    ENDIF
  639.    IF LEN(TRIM(text6)) > 0
  640.       _swte_txt(wn1, text6)
  641.    ENDIF
  642.  
  643.    ***********************************
  644.    * Begin left scroll demonstration *
  645.    ***********************************
  646.    DO WHILE scroll > -10
  647.       IF numrow + trow < 22
  648.          @ numrow + trow + 2, 0 SAY "Press Any Key to See Scroll Left"
  649.          INKEY(0)
  650.       ELSE
  651.          @ trow - 1, 0 SAY "Press Any Key to See Scroll Left"
  652.          INKEY(0)
  653.       ENDIF
  654.       scroll = scroll - 1
  655.       _scrl_vert(wn1,scroll)
  656.       IF LEN(TRIM(text1)) > 0
  657.          _swte_txt(wn1, text1)
  658.       ENDIF
  659.       IF LEN(TRIM(text2)) > 0
  660.          _swte_txt(wn1, text2)
  661.       ENDIF
  662.       IF LEN(TRIM(text3)) > 0
  663.          _swte_txt(wn1, text3)
  664.       ENDIF
  665.       IF LEN(TRIM(text4)) > 0
  666.          _swte_txt(wn1, text4)
  667.       ENDIF
  668.       IF LEN(TRIM(text5)) > 0
  669.          _swte_txt(wn1, text5)
  670.       ENDIF
  671.       IF LEN(TRIM(text6)) > 0
  672.          _swte_txt(wn1, text6)
  673.       ENDIF
  674.    ENDDO
  675.  
  676.    ************************************
  677.    * Begin right scroll demonstration *
  678.    ************************************
  679.    DO WHILE scroll < 0
  680.       IF numrow + trow < 22
  681.          @ numrow + trow + 2, 0 SAY "Press Any Key to See Scroll Right"
  682.          INKEY(0)
  683.       ELSE
  684.          @ trow - 1, 0 SAY "Press Any Key to See Scroll Right"
  685.          INKEY(0)
  686.       ENDIF
  687.       scroll = scroll + 1
  688.       _scrl_vert(wn1,scroll)
  689.       IF LEN(TRIM(text1)) > 0
  690.          _swte_txt(wn1, text1)
  691.       ENDIF
  692.       IF LEN(TRIM(text2)) > 0
  693.          _swte_txt(wn1, text2)
  694.       ENDIF
  695.       IF LEN(TRIM(text3)) > 0
  696.          _swte_txt(wn1, text3)
  697.       ENDIF
  698.       IF LEN(TRIM(text4)) > 0
  699.          _swte_txt(wn1, text4)
  700.       ENDIF
  701.       IF LEN(TRIM(text5)) > 0
  702.          _swte_txt(wn1, text5)
  703.       ENDIF
  704.       IF LEN(TRIM(text6)) > 0
  705.          _swte_txt(wn1, text6)
  706.       ENDIF
  707.    ENDDO
  708.  
  709.    IF numrow + trow < 22
  710.       @ numrow + trow + 2, 0 SAY "Press Any Key to Scroll Up 1 Line."
  711.       INKEY(0)
  712.    ELSE
  713.       @ trow - 1, 0 SAY "Press Any Key to Scroll Up 1 Line."
  714.       INKEY(0)
  715.    ENDIF
  716.    _scrl_horz(wn1,1) 
  717.    IF numrow + trow < 22
  718.       @ numrow + trow + 2, 0 SAY "Press Any Key to Scroll Down 1 Line."
  719.       INKEY(0)
  720.    ELSE
  721.       @ trow - 1, 0 SAY "Press Any Key to Scroll Down 1 Line."
  722.       INKEY(0)
  723.    ENDIF
  724.    _scrl_horz(wn1,-1) 
  725.    @ messrow, 0
  726.    @ messrow, 0 SAY "Press any key to Continue"
  727.    INKEY(0)
  728.    _srem_wn(wn1)
  729.    ******************
  730.    * Turn cursor on *
  731.    ******************
  732.    SET CURSOR ON
  733.  
  734.    answer = " "
  735.    @ messrow, 0 CLEAR
  736.    @ messrow, 0 SAY "Do you wish to try again (Y/N) ";
  737.    GET answer PICTURE "!" VALID (answer $"YN")
  738.    READ
  739.    IF answer = "N"
  740.       EXIT
  741.    ENDIF
  742. ENDDO
  743.  
  744. *******************
  745. * Turn cursor off *
  746. *******************
  747. SET CURSOR OFF
  748.  
  749. **********************************************************
  750. * Don't need wn6 in it's current state, so get rid of it *
  751. **********************************************************
  752. _srem_wn(wn6)
  753. CLEAR
  754.  
  755. ****************************
  756. * create a another window. *
  757. ****************************
  758. wn2 = _sinit_wn(0, 18, 79, 5)
  759.  
  760. ********************
  761. * set window color *
  762. ********************
  763. _sst_wncl(wn2, "a/r/h/", "C")
  764. _sst_wncl(wn2, "a/r/h/", "B")
  765.  
  766. **************************************
  767. * draw the window using all defaults *
  768. **************************************
  769. _sdrw_wn(wn2)
  770.  
  771. *************************************
  772. * Write standard text on the screen *
  773. *************************************
  774. @ 02,20 SAY "Demonstration of Windowed Database" 
  775. @ 06,21 SAY "Its as easy as this" 
  776. @ 08,21 SAY "USE <database name>" 
  777. @ 09,21 SAY 'cur_record = _wn_dbf(wn,"Field" [,"Field" ,"Field"....])'
  778. @ 10,02 SAY "A place to put                                      " 
  779. @ 11,02 SAY "the record #  ─────────┘          │     │      │        │        optional, up" 
  780. @ 12,02 SAY "Returned.                         │     │      │        └─────── to 10 fields" 
  781. @ 13,36 SAY "│     │      │                 allowed." 
  782. @ 14,14 SAY "Call the              │     │      │             The field names" 
  783. @ 15,14 SAY "function.  ───────────┘     │      └─────────────To write." 
  784. @ 16,42 SAY "│     The window" 
  785. @ 17,42 SAY "└──── to write in." 
  786.  
  787. *********************************
  788. * now write text in the window. *
  789. *********************************
  790. _swte_txt(wn2, SPACE(25) + "The following Keys are active")
  791. _swte_txt(wn2, SPACE(10) + "<ESC> - Terminate Windowed Database, returning 0.")
  792. _swte_txt(wn2, SPACE(10) + "<CR> - Terminate Windowed Database returning record number.")
  793. _swte_txt(wn2, SPACE(10) + "Left Arrow - Scroll left.       Right Arrow - Scroll Right.")
  794. _swte_txt(wn2, SPACE(10) + "Up Arrow - Scroll up.           Down Arrow - Scroll Down.")
  795.  
  796. ********************************
  797. * initialize wn6 for use again *
  798. ********************************
  799. wn6 = _sinit_wn(0,3,28,1)
  800.  
  801. ************************************************
  802. * test to make sure the window was initialized *
  803. ************************************************
  804. IF wn6 = 0
  805.    @ messrow,0 SAY "Unable to create window wn6"
  806.    WAIT
  807. ELSE
  808.    *******************************
  809.    * set window border character *
  810.    *******************************
  811.    if .not. _sst_wnbc(wn6, single)
  812.       @ messrow,0 SAY "Unable to set border character. Default of Space used."
  813.    endif
  814.  
  815.    ****************************************************
  816.    * draw the window on the screen and write the text *
  817.    ****************************************************
  818.    _sdrw_wn(wn6)
  819.    _swte_txt(wn6, " Press Any Key To Proceed. ")
  820.  
  821.    ****************************************
  822.    * do the following little number to be *
  823.    * sure you have operators attention    *
  824.    ****************************************
  825.    wncol = 0
  826.    wnrow = 3
  827.    loppsw = .T.
  828.    DO WHILE loopsw
  829.       **********************************************
  830.       *  this loop moves window from left to right *
  831.       **********************************************
  832.       FOR wncol = 0 TO 500
  833.          **********************************************
  834.          * move the window to new column, row coords. *
  835.          **********************************************
  836.          _smove_wn(wn6, wncol, wnrow)
  837.          key = INKEY()     
  838.          IF key <> 0
  839.             loopsw = .F.
  840.             EXIT
  841.          ENDIF
  842.       NEXT
  843.       IF .NOT. loopsw
  844.          LOOP
  845.       ENDIF
  846.       *********************************************
  847.       * this loop moves window from right to left *
  848.       *********************************************
  849.       FOR wncol = 500 TO 0 STEP -1
  850.          **********************************************
  851.          * move the window to new column, row coords. *
  852.          **********************************************
  853.          _smove_wn(wn6, wncol, wnrow)
  854.          key = INKEY()     
  855.          IF key <> 0
  856.             loopsw = .F.
  857.             EXIT
  858.          ENDIF
  859.       NEXT
  860.    ENDDO
  861. ENDIF
  862.  
  863. **************
  864. * remove wn6 *
  865. **************
  866. _srem_wn(wn6)
  867.  
  868. **********************************************
  869. * create a new window. this will demonstrate *
  870. * writing info using a database.             *
  871. **********************************************
  872. wn3 = _sinit_wn(5, 3, 70, 10)
  873.  
  874. ***********************************************
  875. * if wn3 = 0, window initialization failed    *
  876. * due to insufficient memory. Test it and see *
  877. ***********************************************
  878. IF wn3 = 0        
  879.    @ messrow,0 SAY "Not enough memory to execute window functions,"
  880.    @ messrow + 1, 0 SAY "or invalid parameters were passed."
  881.    RETURN
  882. ENDIF
  883.  
  884. ************************
  885. * set border character *
  886. ************************
  887. _sst_wnbc(wn3, single)
  888.  
  889. ********************
  890. * set window color *
  891. ********************
  892. color = 'b/w/h/'
  893. where = 'C'
  894. IF TRIM(color) > " "
  895.    _sst_wncl(wn3, color, where)
  896.    _sst_wncl(wn3, color, "B")
  897. ENDIF
  898.  
  899. ******************************************      
  900. * Ready to put the window on the screen. *
  901. ******************************************
  902. IF .NOT. _sdrw_wn(wn3)
  903.    @ messrow, 0 SAY "Unable to draw window on screen"
  904.    @ messrow + 1, 0 SAY "because invalid parameters were passed."
  905.    RETURN
  906. ENDIF
  907.  
  908. **********************
  909. * open the database. *
  910. **********************
  911. USE customer
  912.  
  913. *******************************
  914. * set pointer color prior to  *
  915. * calling the wn_dbf function *
  916. ******************************* 
  917. _sst_ptcl(wn3, "c/o/h/")
  918.  
  919. ***************************************
  920. * now view the database in the window *
  921. ***************************************
  922. currec = _wn_dbf(wn3, "custno", "comp_name", "comp_addr1", "comp_addr2", "comp_city", "comp_state", "comp_zip", "comp_phone")
  923.  
  924. *******************************************************
  925. * open another window to show record number returned. *
  926. *******************************************************
  927. wn4 = _sinit_wn(20,10,40,10)
  928. _sst_wnbc(wn4, double)
  929. _sst_wncl(wn4, "b/c/h/", "C")
  930. _sdrw_wn(wn4)
  931. _swte_txt(wn4, " ")
  932. _swte_txt(wn4, "Record pointer returned is " + STR(currec))
  933. _swte_txt(wn4, "Press any key to continue")
  934. INKEY(0)
  935.  
  936. **********************************
  937. * remove the windows from memory *
  938. **********************************
  939. _srem_wn(wn4)
  940. _srem_wn(wn3)
  941. _srem_wn(wn2)
  942.  
  943. ******************
  944. * Turn cursor on *
  945. ******************
  946. SET CURSOR ON
  947.  
  948. *******************************
  949. * Demonstrate windowing using *
  950. * Clippers  memo utilities.   *
  951. * This is new to WDEMO.PRG    *
  952. *******************************
  953. CLEAR
  954.  
  955. *************************************
  956. * write standard text to the screen *
  957. * in a different way.               *
  958. *************************************
  959. TEXT
  960.  
  961.          This portion of the demo program will present techniques
  962.        that can be used with Windows For Clipper, and a memo 
  963.        function provided with the compiler. The same techniques
  964.        can also be applied to the dbedit function, although it
  965.        may be difficult to determine where the dbedit function will
  966.        place the information. 
  967.  
  968.          In the following demonstration a window will be created, and 
  969.        help text that explains the cursor controls will be written to
  970.        the window. Next the MEMOEDIT function will be called. The 
  971.        screen coordinates required by the MEMOEDIT function will be 
  972.        inside the window. At that point the MEMOEDIT function will 
  973.        take control until you terminate it. Once terminated, the 
  974.        window will be removed and this text should re-appear. 
  975.         
  976.        
  977.                        Press Any Key To Continue
  978. ENDTEXT
  979. ************************
  980. * wait for a key press *
  981. ************************
  982.  
  983. INKEY(0)
  984.  
  985. *****************************
  986. * Create a window to cover  *
  987. * the entire screen.        *
  988. *****************************
  989. wn1 = 0
  990. wn1 = _sinit_wn(0,0,78,23)
  991.  
  992. *****************************************
  993. * If we made it this far, no need to be *
  994. * sure if the window will be created.   *
  995. * So, set the border character.         *
  996. *****************************************
  997. _sst_wnbc(wn1, double)
  998.  
  999. *************************************
  1000. * now draw the window on the screen *
  1001. *************************************
  1002. _sdrw_wn(wn1)
  1003.  
  1004. ********************************
  1005. * Write the help information   *
  1006. * to the window using Clipper. *
  1007. ********************************
  1008. @ 01,32 SAY "Cursor Control"
  1009. @ 02,05 SAY ""+chr(24)+" or ^E  = Move up a line            HOME  = Beginning of current line"
  1010. @ 03,05 SAY ""+chr(25)+" or ^X  = Move down a line          END   = End of current line"
  1011. @ 04,05 SAY ""+chr(27)+" or ^S  = Move left a char.         ^HOME = Beginning of text"
  1012. @ 05,05 SAY ""+chr(26)+" or ^D  = Move right a char.        ^END  = End of text"
  1013. @ 06,05 SAY "^"+chr(27)+" or ^A = Move left a word          PgUp  = Jump to previous page"
  1014. @ 07,05 SAY "^"+chr(26)+" or ^F = Move right a word         PgDn  = Jump to next page"
  1015. @ 08,05 SAY "^PgUp    = Jump to top of screen     ^PgDn = Jump to bottom of screen"
  1016. @ 09,00 SAY "╠══════════════════════════════════════════════════════════════════════════════╣"
  1017. @ 10,29 SAY "Delete & Exit Control"
  1018. @ 11,12 SAY "^Y = Delete current line             ^B = Reformat text"
  1019. @ 12,12 SAY "^T = Delete word right               ESC = Exit no Save"
  1020. @ 13,30 SAY "^W = Exit with Save"
  1021. @ 14,00 SAY "╠══════════════════════════════════════════════════════════════════════════════╣"
  1022. * "══════════════════════════════════════════════════════════════════════════════"
  1023.  
  1024. ***********************************************
  1025. * Okay, time to access the memoedit function. *
  1026. * The previous database is still in use.      *
  1027. * Position the record pointer to record 10.   *
  1028. * This is where the demo text is located in   *
  1029. * the memo file. One thing, if you decided to *
  1030. * to use this feature in this way, you need   *
  1031. * to be sure of is that the MEMOEDIT row,     *
  1032. * column coordinates do not exceed the        *
  1033. * boundaries of the window.                   *
  1034. ***********************************************
  1035. GOTO(10)
  1036. REPLACE memo1 With MEMOEDIT(memo1, 15,1,23,78,.t.)
  1037.  
  1038. *******************************
  1039. * on return from the memoedit *
  1040. * function remove the window. *
  1041. *******************************
  1042. _srem_wn(wn1)
  1043.  
  1044. ********************
  1045. * Closing remarks. *
  1046. ********************
  1047. @ 16,0 CLEAR
  1048. @ 19,15 SAY "The Windows For Clipper Demo is now over."
  1049. @ 20,15 SAY "I hope you enjoyed this demo. For more "
  1050. @ 21,15 SAY "information on Windows For Clipper, read the "
  1051. @ 22,15 SAY "source file for this demo that is included."
  1052. @ 24,15 SAY "     Press Any Key To Continue"
  1053. INKEY(0)
  1054.  
  1055. RETURN
  1056.